package lbhlll;

public class ThreadLocalDemo {
    static ThreadLocal threadLocal=new ThreadLocal();

    public static void main(String[] args) {

        new Thread(new Runnable() {
            @Override
            public void run() {
                threadLocal.set(1);
            }
        }, "AA").start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                threadLocal.set(2);
                threadLocal.remove();
                System.out.println("线程B中threadLocal的值为："+threadLocal.get());
            }
        }, "bb").start();
        threadLocal.set(3);
        System.out.println("main线程中threadLocal的值为："+threadLocal.get());
    }
}
